package com.sqlcheck.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.servers.Server;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

@Configuration
public class OpenApiConfig {

        @Value("${server.port:8094}")
        private String serverPort;

        @Bean
        public OpenAPI customOpenAPI() {
                return new OpenAPI()
                                .info(new Info()
                                                .title("SQL兼容性检查工具平台 API")
                                                .description("提供SQL兼容性分析、项目扫描、报告生成等功能的RESTful API")
                                                .version("1.0.0")
                                                .contact(new Contact()
                                                                .name("SQL Check Team")
                                                                .email("sqlcheck@company.com")
                                                                .url("https://github.com/company/sqlcheck"))
                                                .license(new License()
                                                                .name("MIT License")
                                                                .url("https://opensource.org/licenses/MIT")))
                                .servers(List.of(
                                                new Server()
                                                                .url("http://localhost:" + serverPort)
                                                                .description("本地开发环境"),
                                                new Server()
                                                                .url("https://api.sqlcheck.company.com")
                                                                .description("生产环境"),
                                                new Server()
                                                                .url("https://test-api.sqlcheck.company.com")
                                                                .description("测试环境")));
        }
}